package com.itheima.dao;


import com.github.pagehelper.Page;
import com.itheima.entity.QueryPageBean;
import com.itheima.health.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CheckItemDao {
    //添加检查项
    @Insert("insert into t_checkitem values(null , #{code} , #{name} " +
            ", #{sex}, #{age} , #{price} , #{type} , #{attention} , #{remark})")
    int add(CheckItem checkItem);


    //分页模糊动态查询
    Page<CheckItem> findPage(QueryPageBean queryPageBean);


    //先检查是否有被检查组使用
    @Select("select count(*) from t_checkgroup_checkitem where checkitem_id = #{id} ")
    long findUserCountById(int id);

    //删除检查项
    @Delete("delete from t_checkitem where id = #{id}")
    int delete(int id);

    //编辑检查项
    @Update({"update t_checkitem set code = #{code}, name = #{name}, " +
            "sex=#{sex},age=#{age},price=#{price},type=#{type}," +
            "attention=#{attention},remark=#{remark} where id = #{id}"})
    int update(CheckItem checkItem);
}
